<?php

namespace App\Admin\Controllers\TradingStream;

use App\Model\Trading_stream;

use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Facades\Admin;
use Encore\Admin\Layout\Content;
use App\Http\Controllers\Controller;
use Encore\Admin\Controllers\ModelForm;

class TradingStreamController extends Controller
{
    use ModelForm;

    /**
     * Index interface.
     *
     * @return Content
     */
    public function index()
    {
        return Admin::content(function (Content $content) {

            $content->header('订单管理');
            $content->description('交易流水');

            $content->body($this->grid());
        });
    }

    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        return Admin::grid(Trading_stream::class, function (Grid $grid) {

            $grid->trading_stream_id("ID")->sortable();
            $grid->user("创建者")->display(function ($user) {
                return "" . $user["nickname"] . "";

            });
            $grid->change("变化");
            $grid->info("说明");
            $grid->type("类型");
            $grid->created_at("创建时间");
            $grid->updated_at("更新时间");

        });
    }

    /**
     * Edit interface.
     *
     * @param $id
     * @return Content
     */
    public function edit($id)
    {
        return Admin::content(function (Content $content) use ($id) {

            $content->header('订单管理');
            $content->description('交易流水');

            $content->body($this->form()->edit($id));
        });
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        return Admin::form(Trading_stream::class, function (Form $form) {
            $form->display('trading_stream_id', 'trading_stream_id');
            $form->display('user_id', 'user_id');
            $form->display('change', 'change');
            $form->display('info', 'info');
            $form->display('type', 'type');
            $form->display('created_at', 'created_at');
            $form->display('updated_at', 'updated_at');
        });
    }

    /**
     * Create interface.
     *
     * @return Content
     */
    public function create()
    {
        return Admin::content(function (Content $content) {

            $content->header('订单管理');
            $content->description('交易流水');

            $content->body($this->form());
        });
    }
}
